package com.zf.shuashua.advert;

import android.text.TextUtils;

import com.zf.shuashua.ShuaApplication;
import com.zf.shuashua.utils.TimeUtils;

import java.util.Date;

/**
 * 各个渠道审核配置
 * vivo渠道：1、不出开屏； 2、移动网络下下载需要提示； 3、不出现游戏界面、热启动开屏
 * huawei渠道： 1、任何网络下下载都需要提示; 2、不出现游戏界面、热启动开屏
 * xiaomi渠道：1、不出现游戏界面、热启动开屏
 */
public class CommitUtils {
    //与后端交互的版本号，做向下兼容
    public static final String API_VERSION = "8";

    private static final String HUAWEI_START_TIME = "2021-1-05";
    private static final String HUAWEI_END_TIME = "2021-1-8";

    private static final String VIVO_START_TIME = "2021-1-05";
    private static final String VIVO_END_TIME = "2021-1-8";

    private static final String XIAOMI_START_TIME = "2021-1-05";
    private static final String XIAOMI_END_TIME = "2021-1-8";

    private static final String OPPO_START_TIME = "2021-1-05";
    private static final String OPPO_END_TIME = "2021-1-8";

    /**
     *
     * @return true: OPPO审核中
     */
    public static boolean isOppoClose(){
        if("oppo".equals(ShuaApplication.channel) && TimeUtils.belongCalendarStr(new Date(), CommitUtils.OPPO_START_TIME, CommitUtils.OPPO_END_TIME)){
            return true;
        }
        return false;
    }

    /**
     *
     * @return true: vivo审核中
     */
    public static boolean isVivoClose(){
        if("vivo".equals(ShuaApplication.channel) && TimeUtils.belongCalendarStr(new Date(), CommitUtils.VIVO_START_TIME, CommitUtils.VIVO_END_TIME)){
            return !ShuaApplication.isVivoOpen;
        }
        return false;
    }

    /**
     *
     * @return true: huawei审核中
     */
    public static boolean isHuaweiClose(){
        if("huawei".equals(ShuaApplication.channel) && TimeUtils.belongCalendarStr(new Date(), CommitUtils.HUAWEI_START_TIME, CommitUtils.HUAWEI_END_TIME)){
            return !ShuaApplication.isHuaweiOpen;
        }
        return false;
    }

    /**
     *
     * @return true: 不显示游戏、热启动开屏
     */
    public static boolean isCloseGame(){
        if(TextUtils.isEmpty(ShuaApplication.channel)){
            return false;
        }
        if("vivo".equals(ShuaApplication.channel) && TimeUtils.belongCalendarStr(new Date(), CommitUtils.VIVO_START_TIME, CommitUtils.VIVO_END_TIME)){
            return !ShuaApplication.isVivoOpen;
        }
        if("huawei".equals(ShuaApplication.channel) && TimeUtils.belongCalendarStr(new Date(), CommitUtils.HUAWEI_START_TIME, CommitUtils.HUAWEI_END_TIME)){
            return !ShuaApplication.isHuaweiOpen;
        }
//        if("xiaomi".equals(ShuaApplication.channel) && TimeUtils.belongCalendarStr(new Date(), CommitUtils.XIAOMI_START_TIME, CommitUtils.XIAOMI_END_TIME)){
//            return !ShuaApplication.isXiaomiOpen;
//        }
        return false;
    }

    public static boolean isXiaomiOpen(){
        if("xiaomi".equals(ShuaApplication.channel)){
            return !ShuaApplication.isXiaomiOpen;
        }
        return false;
    }

    /**
     *
     * @return true:显示全屏视频
     */
    public static boolean isFullVideo(){
        if(TextUtils.isEmpty(ShuaApplication.channel)){
            return false;
        }
        if("vivo".equals(ShuaApplication.channel) && TimeUtils.belongCalendarStr(new Date(), CommitUtils.VIVO_START_TIME, CommitUtils.VIVO_END_TIME)){
            return !ShuaApplication.isVivoOpen;
        }
        if("huawei".equals(ShuaApplication.channel) && TimeUtils.belongCalendarStr(new Date(), CommitUtils.HUAWEI_START_TIME, CommitUtils.HUAWEI_END_TIME)){
            return !ShuaApplication.isHuaweiOpen;
        }
        return false;
    }

}
